Cartesian vector to polar angles conversion.
[phi,theta] = vec2ang(x)
This function converts cartesian coordinates to polar angles. Given one or
more cartesian column vectors in x, vec2ang returns
the corresponding polar angles phi and theta,
both in radians.
phi denotes the counterclockwise angle between the x axis
and the projection of a vector onto the xy plane (azimuth),
theta is the angle between a vector and the z axis
(polar angle, colatitude, elevation complement).
x must be a 3xN array, since vectors are assumed to be along
columns. The vectors can have arbitrary length.
A set of vectors with linearly increasing z coordinate gives polar
angles, where theta is not linearly decreasing.
x = ones(3,6); x(3,:) = linspace(0,9,6); [p,t] = vec2ang(x); t*180/pi
ans = 90.0000 38.1558 21.4467 14.6757 11.1125 8.9301